var second = document.getElementById("second")
var containersecond = document.getElementById("containersecond")
var minute = document.getElementById("minute")
var hour = document.getElementById("hour")
var time = document.getElementById("time")
var time2 = document.getElementById("time2")
var night = document.getElementById("night")
var bg= document.getElementById("bg")
var smallbackground = document.getElementById("smallbackground")
var timecount = 0
var number=document.getElementsByClassName("number");
// 时钟刻度
for(i=0;i<number.length-1;i++){
number[i].style.setProperty("--rotation",(i+1)*30+"deg")
}
night.onclick = function () {
    if (timecount == 0) {
        night.src = "image/月亮.webp"
        bg.src="image/黑夜.webp"
        timecount++
    } else {
        night.src = "image/太阳.webp"
        bg.src="image/白天.webp"
        timecount = 0
    }
}

function clock() {
    var d = new Date()
    var minuteHandle = d.getMinutes() * 6 + d.getSeconds() / 10
    var hourHandle = d.getHours() * 30 + d.getMinutes() / 2
    var secondHandle = d.getSeconds() * 6
    second.style.setProperty("--rotation", secondHandle + "deg")
    minute.style.setProperty("--rotation", minuteHandle + "deg")
    hour.style.setProperty("--rotation", hourHandle + "deg")
}


setInterval(function(){
    var e = new Date()
    var i = new Array()
    i = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Agu", "Sep", "Oct", "Nov", "Dec"]
    time.innerHTML = e.getHours() + ":" + e.getMinutes()
    time2.innerHTML = e.getDate() + i[e.getMonth()] + "," + e.getFullYear()
},1000)
setInterval(clock, 1000)
